package com.xht.security.core.userdetails;

import org.springframework.core.Ordered;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
 * <h1>描述 ：加载用户特定数据的核心</h1>
 * 它在整个框架中用作用户DAO，并且是{@link org.springframework.security.authentication.dao.DaoAuthenticationProvider}使用的策略。
 *
 * @author : 小糊涂
 * @version : 1.0
 * @see org.springframework.security.authentication.dao.DaoAuthenticationProvider
 * @see UserDetails
 **/
public interface XhtUserDetailsService extends UserDetailsService, Ordered {

    /**
     * 是否支持此客户端校验
     *
     * @param clientId 目标客户端
     * @return true/false
     */
    boolean support(String clientId, String grantType);

    /**
     * 通过用户实体查询
     *
     * @param xhtUser XhtUser
     * @return UserDetails
     */
    default UserDetails loadUserByUser(XhtUser xhtUser) {
        return this.loadUserByUsername(xhtUser.getUsername());
    }

}
